package assdraw2.toolbaragent;

import assdraw2.common.MessageType;
import assdraw2.common.PACAgent;
import assdraw2.common.PACMessage;
import assdraw2.toolbaragent.presentation.ToolbarPresentation;

public class ToolbarControl implements PACAgent{

	
	private PACAgent parent;
	private ToolbarPresentation presentation;

	public ToolbarControl(PACAgent parent) {
		this.parent = parent;
	}
	
	@Override
	public void receiveMessage(PACMessage m) {
		if(m.getType() == MessageType.OPEN){ 				
			presentation = new ToolbarPresentation(this);
		}else if(m.getType() == MessageType.CLOSE){
			presentation.dispose();
		}
		
	}

	@Override
	public void sendMessage(PACMessage m) {
			parent.receiveMessage(m);
		
	}
	
	public PACAgent getParentAgent() {
		return parent;
	}

}
